package com.net.shop.car.manager.api.volley.response.jifen;

import org.json.JSONException;
import org.json.JSONObject;

import com.net.shop.car.manager.api.model.JifenGoodDetail;
import com.net.shop.car.manager.api.volley.Response;
import com.net.shop.car.manager.utils.Constants;
import com.net.shop.car.manager.utils.LogUtils;
import com.net.shop.car.manager.utils.StringUtils;

public class JifenGoodDetailResponse extends Response {

	private JifenGoodDetail jifenGoodDetail;
	/**
	 * @return the jifenGoodDetail
	 */
	public JifenGoodDetail getJifenGoodDetail() {
		return jifenGoodDetail;
	}

	public JifenGoodDetailResponse(String type) {
		super(type);
	}

	@Override
	public String getContentTag() {
		if (Constants.JIFEN_DETAIL_OILCARD.equals(getType())) {
			return "card_obj";
		} else {
			return "service_obj";
		}
	}
	
	@Override
	public void parseContent(String content) {
		try {
			JSONObject jsonObject = new JSONObject(content);
			jifenGoodDetail = new JifenGoodDetail();
			jifenGoodDetail.setGoodName(StringUtils.filterNull(jsonObject.getString("PRODUCT_NAME")));
			jifenGoodDetail.setGoodId(StringUtils.filterNull(jsonObject.getString("ID")));
			jifenGoodDetail.setGoodLogo(StringUtils.filterNull(jsonObject.getString("PRODUCT_IMAGE")));
			jifenGoodDetail.setGoodDes(StringUtils.filterNull(jsonObject.getString("PRODUCT_DESC")));
			jifenGoodDetail.setSellerId(StringUtils.filterNull(jsonObject.getString("SELLER_ID")));
			jifenGoodDetail.setPointsRequested(StringUtils.filterLongNull(jsonObject.getString("POINTS_REQUIRED")));
			jifenGoodDetail.setMemeberVb(StringUtils.filterLongNull(jsonObject.getString("mvb")));
			if (Constants.JIFEN_DETAIL_SERVICE.equals(getType())) {
				jifenGoodDetail.setTels(StringUtils.filterTelsNull(jsonObject.getString("TEL")));
			} 
		} catch (JSONException e) {
			LogUtils.e(e.getMessage());
		}
	}
}
